home *** CD-ROM | disk | FTP | other *** search
INI File | 2001-09-10 | 1.8 KB | 45 lines |
- [Name]
- EdgeSpin - From Matthew's Motion Suite.
- By Matthew Peterson, matthew@pinoko.berkeley.edu
-
- [Description]
- 2-19-2000
- Drop this on a sprite, and it will spin in 3D
-
- [Parameters]
-
- [Frame loaded]
- Spritevars MP_flipangle MP_flipheight MP_flipanglestep MP_boxheight MP_scx MP_scy
-
- MP_flipanglestep = 180/17 //Use a divisor of 180, but not 90.
- // if we rotate by 90, we won't be able to see the sprite because
- //it is being viewed along the edge.
- MP_scx = spriteofid($thisspriteid).secondcornerx //Setup the edge of the sprite
- MP_scy = spriteofid($thisspriteid).secondcornery
- //remember how tall the sprite is:
- MP_boxheight = spriteofid($thisspriteid).boundsbottom - spriteofid($thisspriteid).boundstop
- [Idle]
- SpriteVars MP_flipangle flipheight MP_flipanglestep MP_boxheight MP_scx MP_scy
- //EdgeSpin By Matthew Peterson
- // This behavior gives the illusion of 3D by
- // flipping the sprite along its edge. It flips
- // over and over in one direction, then hits
- // the border of the track and returns in the
- // other direction. Perspective is calculated
- // which is unusual since it requires sine and
- // cosine. This is calculated by rotating the
- // sprite and taking the ratio of hight and
- // width. It is a subtle and fast calcuation.
- MP_flipangle = MP_flipangle + MP_flipanglestep
- IF(MP_flipangle <= 0)// Stay within 720 degrees.
- MP_flipangle = MP_flipangle + 360
- ELSEIF(MP_flipangle >= 720)
- MP_flipangle = MP_flipangle rem 360
- ENDIF
- ResetMatrix
-
- Rotate(MP_flipangle)//Rotate in order to make trig calculations:
- flipheight = (SecondCornerY - FirstCornerY) * 0.2
- Stretch(FirstCornerX,SecondCornerY - flipheight,SecondCornerX, SecondCornerY, SecondCornerX,SecondCornerY + MP_boxheight,FirstCornerX,SecondCornerY + MP_boxheight + flipheight)
- MoveBy(MP_scx- SecondCornerX,MP_scy - SecondCornerY)
-